package com.robinmouren.utils;

import com.robinmouren.entity.OrderStatus;

import java.util.Arrays;
import java.util.List;

public class ListUtils {


    /**
     * 去掉string类型的列表的括号
     * @param list
     * @return
     */
    public static String removeStringListConclusion(List<String> list){
        return list.toString()
                .replace("[","")
                .replace("]","");
    }


    /**
     * 返回集合中有效字段的数量
     * @param list
     * @return
     */
    public static Integer fetchStatusInStepsList(List<OrderStatus> list){
        if(list.size() < 1){return -1;}
        if(list.get(list.size() - 1).getTime() != null){
            return list.size();
        }
        return (int) list.stream().filter(item -> item.getTime() != null).count();
    }
}
